﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;

namespace KnowFirstWebApplication
{
    public partial class PersonalSettings : basePageSessionExpire
    {
        public const string USERNAME = "UserName";
        public const string CATEGORY = "Category";
     
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadUserDetails();
        }

        private void LoadUserDetails()
        {
            User currentUser = Results.GetUser(Session[USERNAME] as string);
            tbUserName.Text = currentUser.UserName;
            tbUserName.Enabled = false;
            tbFirstName.Text = currentUser.FirstName;
            tbEmail1.Text = currentUser.Email;

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            Dal.DatabaseAbstractionLayer dal = new Dal.DatabaseAbstractionLayer();
            dal.UpdateUserDetails(tbUserName.Text, tbFirstName.Text, tbFirstName.Text,
                tbPassword.Text, tbEmail1.Text);
            tbPassword.Text = string.Empty;
            tbPasswordConfirm.Text = string.Empty;
        }
    }
}
